package serviceimpl;

import beans.Member;
import dao.UserDao;
import daoIpmt.UserDaoIpmt;
import service.MemberService;

public class MemberServiceIpmt implements MemberService{
	UserDao ud=new UserDaoIpmt();

	@Override
	public void Regist(Member member) {
		ud.addUser(member);
	}

	@Override
	public Member login(String username, String password) {
		UserDao ud = new UserDaoIpmt();
		Member member = ud.getUserByUsernameAndPwd(username, password);
		if (member != null) {
			return member;
		} else {
			throw new RuntimeException("用户名/密码错误");
		}

	}

	@Override
	public Member getMemberByUsername(String username) {
		Member member=ud.getMemberByUsername(username);
		return member;
	}

	@Override
	public Member getMemberById(int id) {
		return ud.getUserById(id);
	}

	@Override
	public void like(Member member) {
		ud.inheat(member);
	}
	@Override
	public void unLike(Member member) {
		ud.deheat(member);
	}

}
